//
//  main.c
//  Job_Scheduling
//
//  Created by zhangyukun on 2021/4/21.
//

#include <stdio.h>
#include "job_schedulingn.h"

int main() {
    //create and initialize waiting list and ready list .
    LIST_HEAD(head_of_wait_list);
    LIST_HEAD(head_of_H_ready_list);
    LIST_HEAD(head_of_M_ready_list);
    LIST_HEAD(head_of_L_ready_list);
    //create two pointer pointing to waiting list and ready list .
    struct list_head *wait_head;
    struct list_head *ready_H_head;
    struct list_head *ready_M_head;
    struct list_head *ready_L_head;
    wait_head = &head_of_wait_list;
    ready_H_head = &head_of_H_ready_list;
    ready_M_head = &head_of_M_ready_list;
    ready_L_head = &head_of_L_ready_list;
    struct list_head* ready_heads[] = {ready_H_head,ready_M_head,ready_L_head};
    read_data(wait_head);           //read data from file .
    init_JCB(wait_head);            //initialize JCB .
    Print_JCB(wait_head);           //print information .
    printf("FCFS:\n");
    FCFS(wait_head, ready_heads[0]);    //run with FCFS scheduling .
    printf("\n");
    printf("SJF:\n");
    SJF(wait_head, ready_heads[0]);     //run with SFJ scheduling .
    printf("\n");
    printf("HPF:\n");
    HPF(wait_head, ready_heads[0]);     //run with HPF scheduling .
    printf("\n");
    printf("HRRN:\n");
    HRRN(wait_head, ready_heads[0]);    //run with HEEN scheduling .
    printf("\n");
    printf("RR:\n");
    RR(wait_head, ready_heads[0]);      //run with RR scheduling .
    printf("\n");
    printf("MFQ:\n");
    MFQ(wait_head, ready_heads);        //run with MFQ scheduling .
    return 0;
}
